﻿"runtime! archlinux.vim

"settings {{{1
	"default settings:
		"set selectmode= textwidth=0 showbreak=
		"set noundofile noinfercase nolist norelativenumber noshiftround noshowmatch nosmarttab
		"set joinspaces ttyfast tagbsearch wrapscan
	"filetype settings:cindent cinkeys showfulltag
	"unsure settings:dictionary include includeexpr updatecount updatetime viewdir maxmem maxmempattern maxmemtot menuitems mkspellmen

	set number more tildeop mouse=a
	set nowrap whichwrap=b,s "只有<BS><SPACE>可以在行间回绕
	set smartindent autoindent copyindent
	"set magic cursorline hidden lazyredraw splitright confirm
	set nofsync nospell nocompatible noruler noshowcmd noshowmode swapsync=sync
	set noincsearch hlsearch ignorecase
	"set noautoread noerrorbells novisualbell t_vb=
	set shortmess=aoOtTI "启动的时候不显示那个援助索马里儿童的提示
	set viminfo= "退出时不保存信息
	set switchbuf=usetab,newtab
	set backspace=indent,eol,start
	set isfname+=32 "让gf也能查找包含space的文件名
	set completeopt=menuone selection=old
	set history=9 undolevels=36 maxfuncdepth=97
	set wildmenu "wildmode=full wildchar=<Tab>
	set diffopt+=vertical matchpairs+=<:> helplang=cn formatoptions+=mM
	"set fileencoding=utf-8
	set fileencodings=usc-bom,utf-8,chinese ",euc-jp,gb18030,gbk,gb2312,cp936
	set ambiwidth=double
	"set encoding=utf-8
	"let &termencoding=&encoding
	set nobackup nowritebackup updatecount=0 backupdir=	"关闭备份功能
	set noswapfile	"可在编辑过程中禁止使用交换文件
	set scrolloff=1	sidescroll=3 sidescrolloff=7
	set shiftwidth=4 tabstop=4 softtabstop=4 noexpandtab
	set nobomb	"设置字节顺序 只有写入的时候才会有效，现在设置是无效的

	"set cmdheight=2 matchtime=7
	"let mapleader="," maplocalleader="\"
	"set notimeout "映射时不检查超时
	"set ttimeout "终端键码检查超时
	"set timeoutlen=100 "超时为100毫秒

	" 用空格键来开关折叠
	"nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
	"set foldmethod=syntax "设置语法折叠
	"set foldcolumn=3 "设置折叠区域的宽度
	"set foldclose=all foldopen=all "设置为自动关闭/打开折叠
	set fdm=marker fdls=1 "foldnestmax=7

	"if has('multi_byte')
	"	set nodelcombine
	"endif
	"if has('windows')
	"	set showtabline=1
	"endif

	if v:version>=703
		set cryptmethod=blowfish
		set concealcursor=nc conceallevel=1
	endif

	set	directory=/tmp/ "将所有.swp发入指定目录
	set fileformat=unix
	set noshelltemp 

	set laststatus=2 highlight+=srb
	let &statusline='%f %m%r    [%{&ft}|%{&fenc}|%{&ff}]   %{exists("g:colors_name")?(g:colors_name):"None"}'

	"set iskeyword+=.	"把.也认为是word的一个合法字符

	"scriptnames	"列出所有加载的 plugins, _vimrcs
	"verbose set history	"显示history的值并指出设置文件的位置

	"plugin settings {{{1
	""taglist.vim {{{2
	"let g:Tlist_Exit_OnlyWindow = 1
	"let g:Tlist_Show_One_File = 1
	"let g:Tlist_Sort_Type = 'name'
	"let g:Tlist_File_Fold_Auto_Close = 1
	"if has('win32')
	"	let g:Tlist_Ctags_Cmd = 'F:\cygwin\bin\ctags.exe'
	"endif

	"tagbar.vim {{{2
	let g:tagbar_left = 1
	if has('win32')
		let g:tagbar_ctags_bin = 'F:\cygwin\bin\ctags.exe'
	endif

	"matchparen.vim {{{2
	"let g:loaded_matchparen = 0

	"autoclose.vim {{{2
	let g:autoclose_on = 1

	"netrw {{{2
	let g:netrw_home = '/opt/hxSystem'

	"autocmd {{{1
	"if has('autochdir')
	"	set autochdir
	"else
	"	autocmd BufEnter * exec "cd %:p:h"
	"endif
	autocmd BufReadPre * call hexing#hexing_autoload#HX_OnOpenFile()
	au BufRead,BufNewFile *.h++	set filetype=cpp
	au BufRead,BufNewFile *.c++	set filetype=cpp

	"command {{{1
	command! -range Align : call hexing#hexing_autoload#HX_align_word_column(<line1>, <line2>)

	"maps {{{1 
	"normal mode {{{2
	"nnoremap <F1> :call hexing#hexing_autoload#HX_debug_test()<CR>
	"nnoremap <silent> <S-Tab> :call hexing#hexing_autoload#HX_switch_showtabline()<CR>
	nnoremap / :nohlsearch<CR>/
	nnoremap ? :nohlsearch<CR>?
	"nnoremap <silent> <Esc> :nohlsearch<CR><Esc>
	"nnoremap Y y$
	"nnoremap <Home> ^
	"nnoremap <Home> 1_
	"nnoremap <silent> <kPlus> :set foldlevel-=1<CR>
	"nnoremap <silent> <kMinus> :set foldlevel+=1<CR>
	"nnoremap <C-F4> :call hexing#hexing_autoload#HX_close_buffer()<CR>
	"nnoremap <silent> <F6> :call  hexing#hexing_autoload#HX_toggle_quickfix_wnd()<CR>
	"nnoremap <silent> <C-F12> :call hexing#hexing_autoload#HX_CreateTagFile()<CR>
	"nnoremap <silent> <A-F12> :call hexing#hexing_autoload#HX_LoadTagFiles('')<CR>
	nnoremap <C-S-Left> gh<C-o>b
	nnoremap <C-S-Right> gh<C-o>w

	"insert mode {{{2
	inoremap <C-S-Left> <C-\><C-o>gh<C-o>b
	inoremap <C-S-Right> <C-\><C-o>gh<C-o>w
	inoremap <C-v> <C-o>"P
	"inoremap <CR> <C-R>=pumvisible() ? "\<lt>C-Y>" : "\<lt>CR>"<CR>
	"inoremap <expr> <Esc> pumvisible() ? "\<C-E>" : "\<Esc>"
	"imap <C-CR> <End><CR>
	"inoremap <S-CR> <C-O>O
	"inoremap <Home> <C-O>^
	"inoremap <silent> <C-S> <C-O>:update<CR>

	"visual mode {{{2
	"vnoremap <silent> <A-F8> :call hexing#hexing_autoload#HX_align_lines()<CR>
	vn <buffer> <silent> <Leader>' :call hexing#hexing_autoload#HX_range_pair("'","'")<CR>
	vn <buffer> <silent> <Leader>" :call hexing#hexing_autoload#HX_range_pair('"','"')<CR>
	vn <buffer> <silent> <Leader>( :call hexing#hexing_autoload#HX_range_pair('(',')')<CR>
	vn <buffer> <silent> <Leader>[ :call hexing#hexing_autoload#HX_range_pair('[',']')<CR>
	vn <buffer> <silent> <Leader>{ :call hexing#hexing_autoload#HX_range_pair('{','}')<CR>
	vn <buffer> <silent> <Leader>< :call hexing#hexing_autoload#HX_range_pair('<','>')<CR>

	runtime! autoload/hexing/hxEmacs.vim

	"addition {{{1
	filetype plugin indent on
	syntax enable
	syntax on

	colorscheme	random

	"{{{ cursor
	if !has('gui_running')
		if &term =~ '^linux'
			set t_te=[2J[?47l[0;0H
			"set t_te=[2J[?47l
			set t_ti=[?47h[2J
			"控制台光标设置为块状
			set  t_ve+=[?6c
			autocmd! InsertEnter * set  t_ve-=[?6c
			autocmd! InsertLeave * set  t_ve+=[?6c
			"autocmd! VimLeave * set  t_ve-=[?6c
		elseif &term =~ '^xterm'
			""block cursor in normal,line cursor in insert
			"let &t_ti.="\e[1 q"
			"let &t_SI.="\e[5 q"
			"let &t_EI.="\e[1 q"
			"let &t_te.="\e[0 q"
			"恢复xterm的屏幕
			"	set t_ti=7[r[?47h t_te=[?47l8
			"	set t_ti=[?1049h t_te=[?1049l
			"	let &t_ti="\<Esc>[?1049h" | let &t_te="\<Esc>[?1049l"
			"	if has('cursorshape') "改变cursor的颜色
			"		let &t_SI="\<Esc>]12;burlywood1\x7" | let &t_EI="\<Esc>]12;green3\x7"
			"	endif
		endif

		"在不同模式下使用不同颜色的光标
		if !exists('$SSH_TTY') "不要在 ssh 下使用
			let color_normal = 'HotPink'
			let color_insert = 'RoyalBlue1'
			let color_exit = 'green'
			if &term =~ 'xterm'
				"exe 'silent !echo -ne "\e[1 q"'
				let &t_SI="\e]12;" . color_insert . "\007"
				let &t_EI="\e]12;" . color_normal . "\a"
				"exe 'autocmd VimLeave * :!echo -ne "\e[5 q"'

				"solid underscore
				let &t_SI .= "\<Esc>[5 q"
				"solid block
				let &t_EI .= "\e[1 q"
				"1 or 0 -> blinking block
				"3 -> blinking underscore
			"elseif &term =~ 'rxvt'
			"	let &t_SI="\e]12;" . color_insert . "\007"
			"	let &t_EI="\e]12;" . color_normal . "\a"
			"	"let &t_SI .= "\<Esc>[5 q"
			"	"let &t_EI .= "\e[1 q"
			elseif &term =~ "screen"
				if !exists('$SUDO_UID') 
					if exists('$TMUX') 
						"exe 'silent !echo -ne "\033Ptmux;\033\e]12;"' . shellescape(color_normal, 1) . '"\007\033\\"'
						let &t_SI="\033Ptmux;\033\ei]12;" . color_insert . "\007\033\\"
						let &t_EI="\033Ptmux;\033\e]12;" . color_normal . "\007\033\\"
						"exe 'autocmd VimLeave * :!echo -ne "\033Ptmux;\033\e]12;"' . shellescape(color_exit, 1) . '"\007\033\\"'
					else
						"exe 'silent !echo -ne "\033P\e]12;"' . shellescape(color_normal, 1) . '"\007\033\\"'
						let &t_SI="\033P\e]12;" . color_insert . "\007\033\\"
						let &t_EI="\033P\e]12;" . color_normal . "\007\033\\"
						"exe 'autocmd VimLeave * :!echo -ne "\033P\e]12;"' . shellescape(color_exit, 1) . '"\007\033\\"'
					endif
				endif
			endif
			unlet color_normal 
			unlet color_insert 
			unlet color_exit 
	endif
endif
"}}}
